<?php
namespace plugin\banmichaoqiangbizhi\admin; 
use plugin\banmichaoqiangbizhi\model\PluginBanmiBanmichaoqiangbizhiSearchKey as models ; 
use plugin\banmichaoqiangbizhi\validate\SearchkeyValidate as validates ;
use app\admin\common\Baseadmin;
use think\facade\Db; 

class Searchkey extends Baseadmin
{
            public function   lists(){  
             $request= (new validates())->IsCheck('lists');
             $field="";
             $map   =[];
             $map[] = ["state", "=", 2 ]; 
             $model =(new models())->paginate($map,$field);
             $data['list']=$model;
             ajaxmsg('ok', 200,$data);  
      }

                   public function views(){  
              $request= (new validates())->IsCheck();
              $field=[];
              $map   =[];
              $map[] = ["id", "=", input('request.id') ]; 
              $model =(new models())->finds($map,$field);
              $data['find']=$model;
              if ($model) {
                     ajaxmsg('成功', 200,$data);
              } 
                  ajaxmsg('内容不存在', 0);
        }
         public function edit(){  
             $request= (new validates())->IsCheck('edit');
             $field=["name","sort","state"];
             $map   =[];
             $map[] = ["id", "=", input('request.id') ]; 
             $request["state"]= 2;
 
                 
             if (input('request.id') > 0) {
                  //编辑
                   $model =(new models())->updates($map,$request,$field);
              } else {
                  //新增
                   $model =(new models())->adds($request,$field);
             } 
                if($model){
                  ajaxmsg('成功', 200);
               }
               ajaxmsg('失败', 0);
        }
       
                public function   dels(){  
             $request= (new validates())->IsCheck('dels');
             $field=["state"];
             $map   =[];
             $map[] = ["id", "=", input('request.id') ]; 
			 $request["state"]= -1;
             $model =(new models())->updates($map,$request,$field);
              if($model){
               ajaxmsg('成功', 200);
              }
               ajaxmsg('失败', 0);
      }

          //控制器方法
    
    
    
}